package com.example.administrator.szb.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.administrator.szb.R;
import com.example.administrator.szb.bean.GWXQBean;

import java.util.List;

/**
 * Created by stone on 2018/1/8.
 */

public class JGDetailTextAdapter extends RecyclerView.Adapter<JGDetailTextAdapter.MyViewHolder> {
    private List<GWXQBean.DataBean.BusinessBean.NextBeanX.NextBean> list;
private Context context;
    public JGDetailTextAdapter(List list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.item_text, parent, false);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        holder.tv.setText(list.get(position).getTitle());
        if (list.get(position).getGenre()==1){
            holder.tv.setTextColor(context.getResources().getColor(R.color.black1));
        }else {

            holder.tv.setTextColor(context.getResources().getColor(R.color.gray1));
        }
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
    class MyViewHolder extends RecyclerView.ViewHolder
    {

        TextView tv;

        public MyViewHolder(View view)
        {
            super(view);
            tv = (TextView) view.findViewById(R.id.textViews);
        }
    }
}

